package com.friend.service.file.impl;

import com.common.core.enums.ResultCode;
import com.common.file.domain.OSSResult;
import com.common.file.service.OSSService;
import com.common.security.exception.ServiceException;
import com.friend.service.file.FileService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Service
public class FileServiceImpl implements FileService {

    @Resource
    OSSService ossService;

    @Override
    public OSSResult upload(MultipartFile file) {
        try{
            return ossService.uploadFile(file);
        }catch (Exception e){
            throw new ServiceException(ResultCode.FAILED_FILE_UPLOAD);
        }
    }
}
